<?php
/*
 * 用户登陆
 */
include '../service/UserService.class.php';
include '../util/class.log.php';

header("Content-type:text/html;charset=utf-8");

$username = $_POST['username'];
$password = $_POST['password'];

/*$username = $_GET['username'];
$password = $_GET['password'];*/

$userService = new UserService();
$userService->emailIsValidation($username);
$result = $userService->login($username, $password);    //验证用户名和密码是否正确
$emailResult = $userService->emailIsValidation($username); //验证邮箱是否验证

if($result == 1 && $emailResult == 1)
{
	$L = log::get_instance();
	$L->log(0,'用户'.$username.'登录系统', date('Y-n-j H:m:s'));
	$L->close();
	$value = array('tip' => 1);
	print_r(json_encode($value));     //用户登录成功
}else if($result == 1 && $emailResult == 0) {
	
	$value = array('tip' => 3);
	print_r(json_encode($value));        //邮箱还未验证
} else if($result == 0 || $result == 2){
	$L = log::get_instance();
	$L->log(0,'用户'.$username.'登录系统', date('Y-n-j H:m:s'));
	$L->close();
	$value = array('tip' => 0);       //用户登录失败
	print_r(json_encode($value));
}